#ifndef _DevicesRS485_H_
#define _DevicesRS485_H_


#define RS485_LOG_GPIO_Port GPIOD
#define RS485_LOG_Pin       GPIO_PIN_11

#define RS485_BUS_GPIO_Port GPIOE
#define RS485_BUS_Pin       GPIO_PIN_15

#define RS485_LOG_MODE_RECEIVE()    gpio_bit_set(RS485_LOG_GPIO_Port, RS485_LOG_Pin)
#define RS485_LOG_MODE_SEND()       gpio_bit_reset(RS485_LOG_GPIO_Port, RS485_LOG_Pin)

#define RS485_BUS_MODE_RECEIVE()    gpio_bit_set(RS485_BUS_GPIO_Port, RS485_BUS_Pin)
#define RS485_BUS_MODE_SEND()       gpio_bit_reset(RS485_BUS_GPIO_Port, RS485_BUS_Pin)



void vRS485LogInit(void);
void vRS485BusInit(void);

int8_t cRS485xSendDatas(uint32_t uiChannel, void *pvBuff, int32_t iLength);
int8_t cRS485xReceiveDatas(uint32_t uiChannel, void *pvBuff, int32_t iLength);
int32_t iRS485xReceiveAllDatas(uint32_t uiChannel, void *pvBuff, int32_t iLengthLimit);
int8_t cRS485xReceiveByte(uint32_t uiChannel, uint8_t *pucBuff);
int32_t iRS485xReceiveLengthGet(uint32_t uiChannel);
int8_t cRS485xReceiveClear(uint32_t uiChannel);


#endif
